fix issue 17933 - Warn in case of implicit truncating float conversion#7240
Conversation
|
Thanks for your pull request, @bbasile! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Some tips to help speed things up:
Bear in mind that large or tricky changes may require multiple rounds of review and revision. Please see CONTRIBUTING.md for more information. Bugzilla references
|
|
Seems like a reasonable addition to me. |
|
If this is deemed a worthy addition, it should be a deprecation not a warning. We should eliminate all warnings. Historically @WalterBright and I have considered conversions from double to float acceptable, so this change (which will break code) needs to be argued properly. |
|
Suppose somebody gets this warning. How do they suppress it? You might think you can do: Until this static assert passes, this PR should be rejected. The underlying problem is that in practice, D is defined to use x87 floating-point semantics, where float and double and real are (almost) the same internally. These semantics work extremely poorly on any other CPU. But unless we tighten our semantics, we can't accept PRs like this one. |
|
It's too late and the required changes make the code ugly. The related phobos PR still misses about 50 unfixed warnings. |
Emit a warning when an implicit conversion from a FP type to another may lead to lose the accuracy of the RHS. Requires a phobos and a druntime change to pass the tests.